package wql.demo04;

/**
 * @author wql
 * @version 1.0
 * @date 2022/10/25 14:32
 */

public class Test {
    public static void main(String[] args) {
        Hai<Integer> hai = new Hai<>();
        hai.setE(123);
        drink(hai);

        Hai<String> hai1 = new Hai<>();
        hai1.setE("你好世界");
        drink1(hai1);
    }
    public static void drink(Hai<? extends Number>hai){
        hai.eat();
    }
    public static void drink1(Hai<? super String>hai){
        hai.eat();
    }
}
class  Hai<T>{
    private T e;
    public void  eat(){
        System.out.println("e = " + e);
    }

    public T getE() {
        return e;
    }

    public void setE(T e) {
        this.e = e;
    }

    @Override
    public String toString() {
        return "Hai{" +
                "e=" + e +
                '}';
    }
}
